package main

import (
	"log"
	"npxy-go/pkg/proxy/server"
	"os"

	"github.com/spf13/cobra"
)

func main() {
	var conf server.Config

	cmd := &cobra.Command{
		Use:          "npxy-srv",
		Long:         "This is new pxy server",
		SilenceUsage: true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return server.Start(&conf)
		},
	}

	cmd.Flags().IntVarP(&conf.BridgePort, "bridge-port", "b", 8100, "specify port of bridge")
	cmd.Flags().StringVarP(&conf.Secret, "secret", "s", "123456", "secret between server and client")
	cmd.Flags().BoolVar(&conf.APIEnable, "api-enable", true, "enable restful api")
	cmd.Flags().Uint16Var(&conf.APIPort, "api-port", 8101, "port of restful api server")

	if err := cmd.Execute(); err != nil {
		log.Println(err)
		os.Exit(1)
		return
	}
}
